// un-/set default configs params 
$(document).bind("mobileinit", function(){
  $.mobile.useFastClick = false;
  //$.mobile.minScrollBack = "infinity"; 
  
});

// navbar handling: mark active page in navbar
/*$('div').live('pagebeforeshow', function(event, ui) {
	// set class attrib 'ui-btn-active' in navbar's list entry, where the href attrib matches to page's id
	var activeLink = $.mobile.activePage.find('div[data-role="navbar"] a[href*="' + $(this).attr('id') + '"]');

	var homeLink = $.mobile.activePage.find('div[data-role="navbar"] a[href*="home"]');
	var gamesLink = $.mobile.activePage.find('div[data-role="navbar"] a[href*="gameactions.html"]');
	var ranksLink = $.mobile.activePage.find('div[data-role="navbar"] a[href*="rankings.html"]');
	
	if (typeof(activeLink.attr('href')) != 'undefined') {
		if (activeLink.attr('href').indexOf(homeLink.attr('href')) != -1) {
			homeLink.addClass('ui-btn-active');
			gamesLink.removeClass('ui-btn-active');
			ranksLink.removeClass('ui-btn-active');
		} else if(activeLink.attr('href').indexOf(gamesLink.attr('href')) != -1) {
			homeLink.removeClass('ui-btn-active');
			gamesLink.addClass('ui-btn-active');
			ranksLink.removeClass('ui-btn-active');
		} else if (activeLink.attr('href').indexOf(ranksLink.attr('href')) != -1) {
			homeLink.removeClass('ui-btn-active');
			gamesLink.removeClass('ui-btn-active');
			ranksLink.addClass('ui-btn-active');
		}
	}
});*/


//
// helper functions used for initial player registration
//
function createPlayer(id, playername, email) {
    return {
        Id: id,
        Playername: playername,
        Email: email,
    };
}

function isPlayerCached() {
	return (localStorage.playerId != null); 
}

function getPlayerFromCache() {
	return createPlayer(localStorage.playerId, localStorage.playername, localStorage.email);
}

function cachePlayer(id, playername, email) {
	localStorage.playerId = id;
	localStorage.playername = playername;
	localStorage.email = email;
}